 var searchRange = function(nums, target) {
    let ans = [-1, -1];
    const leftIdx = binarySearch(nums, target, true);
    const rightIdx = binarySearch(nums, target, false) - 1;
    if ( nums[leftIdx] === target && nums[rightIdx] === target) {
        ans = [leftIdx, rightIdx];
    } 
    return ans;
} 

function efcz(nums,target,result){
    let left = 0
    let right = nums.length-1
    let ans = nums.length
    while(left<=right){
        let mid = Math.floor((left+right)/2)
        if(nums(mid)>target||(result&&nums[mid]>=target)){
            right = mid -1
            ans = mid 
        }else{
            left = mid + 1
        }
        return ans
    }
}